/*******************************************************************************
* CSCI321 Major Project 2010 - University of Wollongong                        *
********************************************************************************
* Program:		WeaveEdit                                              *
* Authors:		Simon Allen (Student#: 3457527, Unix: sa655)           *
*			Scott Bellis (Student#: 3479110, Unix: sjb900)         *
*			Jason Benger (Student#: 3454137, Unix: jb960)          *
*			Timothy Newmarch (Student#: 3459263 Unix: tgn336)      *
*			Benjamin Richardson (Student# 3467752, Unix: bjr401)   *
* Supervisor:		Daniel F. Saffioti                                     *
* Modified:		28/10/2010                                             *
* Description:		WeaveEdit is a highly portable collaborative text      *
*			editor and word processor, allowing several users to   *
*			read and edit multiple documents at the same time.     *
*			It is available for Mac OS X, Windows and Linux,       *
*			utilising Nokia's Qt development framework.            *
*******************************************************************************/


#ifndef PREFERENCES_H
#define PREFERENCES_H

#include "constants.h"
#include "ColourButton/colourbutton.h"

#include <QDialog>
#include <QSettings>


namespace Ui
{
	class Preferences;
}

/**
  * user preferences/settings dialog, with default values.
  * Implemented as a singleton class so that all program scopes can access settings.
  */
class Preferences : public QDialog
{
	Q_OBJECT

	private:
		static Preferences *instance;
		Ui::Preferences *ui;
		ColourButton *pushButton_defaultTextColour;
		QSettings *settings;

	protected:
		Preferences(QWidget *parent = 0);

	public:
		const static char *SETTING_SAVE_WINDOW_GEOMETRY;
		const static char *SETTING_DEFAULT_NAME;
		const static char *SETTING_DEFAULT_TEXT_COLOUR;
		const static char *SETTING_TAB_WIDTH;
		const static char *SETTING_CHARACTER_MATCHING;
		const static char *SETTING_AUTO_COMPLETION;
		const static char *SETTING_AUTO_COMPLETION_PREFIX_LENGTH;
		const static char *SETTING_LONG_LINE_MARKER;
		const static char *SETTING_LONG_LINE_MARKER_POSITION;
		const static char *SETTING_DEFAULT_TEXT_FONT;
		const static char *SETTING_DEFAULT_TEXT_FONT_SIZE;
		const static char *SETTING_DEFAULT_FORMATTED_FONT;
		const static char *SETTING_DEFAULT_FORMATTED_FONT_SIZE;
		const static char *SETTING_USE_SYSTEM_TEXT_FONT;
		const static char *SETTING_USE_SYSTEM_FORMATTED_FONT;

		static Preferences *getInstance()
		{
			if (!instance)
				instance = new Preferences();

			return instance;
		}

		~Preferences();

		void setValue(const QString &name, const QVariant &value);
		QVariant getValue(const QString &name, const QVariant &defaultValue = QVariant()) const;
		void setVisible(bool visible);	//overridden to make sure that the first tab is shown (instead of the last tab open)

	signals:
		void changed();

	public slots:
		void writeSettings();
		void readSettings();

	private slots:
		void clearSettings();
};

#endif // PREFERENCES_H
